export interface State {
  count: number;
}

export const initialState: State = {
  count: 0,
};

export type Action = { type: "INCREMENT" } | { type: "DECREMENT" };

export function reducer(state: State = initialState, action: Action): State {
  switch (action.type) {
    case "INCREMENT":
      return {
        ...state,
        count: state.count + 1,
      };
    case "DECREMENT":
      return {
        ...state,
        count: state.count - 1,
      };
    default:
      return state;
  }
}
